/*
 */

package com.railway.msg.service.impl;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.railway.msg.service.IMsgReciveManager;
import java.util.*;
import org.apache.commons.lang.StringUtils;

import com.railway.common.base.*;
import com.railway.common.util.*;

import cn.org.rapid_framework.util.*;
import cn.org.rapid_framework.web.util.*;
import cn.org.rapid_framework.page.*;
import cn.org.rapid_framework.page.impl.*;

import com.railway.msg.model.*;
import com.railway.msg.dao.*;
import com.railway.msg.service.*;
import com.railway.msg.vo.query.*;

/**
 * @author  jiangcheng
 * @version 1.0
 * @since 1.0
 */


@Service("msgReciveManager")
@Transactional
public class MsgReciveManagerImpl extends BaseManager<MsgRecive,java.lang.String> implements IMsgReciveManager{

	private IMsgReciveDao msgReciveDao;

	public void setMsgReciveDao(IMsgReciveDao dao) {
		this.msgReciveDao = dao;
	}
	public EntityDao getEntityDao() {
		return (EntityDao)this.msgReciveDao;
	}
	
	@Transactional(readOnly=true)
	public Page findPage(MsgReciveQuery query) {
		
		Page p = msgReciveDao.findPage(query);
		List list = p.getResult();
		if(list != null){
			for(int i = 0 ; i < list.size(); i++){
				
				MsgRecive msgrecive = (MsgRecive)list.get(i);
				msgrecive.setCreator(StaticMap.getUserValue(msgrecive.getCreator()));
				msgrecive.setStatus(StaticMap.getMsgStatus(msgrecive.getStatus()));
			}
		}
		return p;
	}
	@Transactional(readOnly=true)
	public MsgRecive getById(java.lang.String id){
		return super.getById( id);
	}
	@Transactional
	public void removeById(java.lang.String id){
		super.removeById(id);
	}
	
	/** 插入数据 */
	@Transactional
	public void save(MsgRecive entity){
		super.save(entity);
	}
	
	/** 更新数据 */
	@Transactional
	public void update(MsgRecive entity){
		super.update(entity);
	}
	@Transactional(readOnly=true)
	public boolean isUnique(MsgRecive entity, String uniquePropertyNames){
		return super.isUnique( entity, uniquePropertyNames);
	}
	@Transactional(readOnly=true)
	public List<MsgRecive> findAll(){
		return super.findAll();
	}
	@Transactional
	public void saveOrUpdate(MsgRecive entity) {
		super.saveOrUpdate(entity);
	}
	@Transactional(readOnly=true)
	public long getMsgCountByUserID(String userid) {		
		return msgReciveDao.getMsgCountByUserID(userid);
	}
	@Transactional(readOnly=true)
	public Page findPageUnreadUsers(MsgReciveQuery query) {
		Page p = null;
		try{
		// TODO Auto-generated method stub
		 p = msgReciveDao.findPageEntity(query);
		List list = p.getResult();
		if(list != null){
			for(int i = 0 ; i < list.size(); i++){
				
				MsgRecive msgrecive = (MsgRecive)list.get(i);
				msgrecive.setRecivor(StaticMap.getUserValue(msgrecive.getRecivor()));
				msgrecive.setStatus(StaticMap.getMsgStatus(msgrecive.getStatus()));
			}
		}
		}catch(Exception e){
			e.printStackTrace();
		}
		return p;
		
	}


}
